package com.titan.demo.camel.sample.component.rabbitmq;

import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;

import com.titan.demo.camel.utils.RunCamel;

public class Test01 {
	public static void main(String[] args) {
        try {
        	RouteBuilder route = createRouteBuilder();
        	createRunCamel().run(route);
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
	
	private static RunCamel createRunCamel() {
		return new RunCamel() {
			protected void execute(CamelContext context,
					ProducerTemplate producer, ConsumerTemplate consumer)
					throws Exception {
				producer.sendBody("direct:in", "Hello World!");
			}
		};
	}
	
	private static RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() throws Exception {
                from("direct:in")
				.to("rabbitmq://127.0.0.1:5672/pickedbus"
								+ "?queue=picked_bus" 
								+ "&username=admin"
								+ "&password=manager" 
								+ "&vhost=/" 
								+ "&routingKey=pickedbus" 
								+ "&autoDelete=false&declare=true")
                ;
            }
        };
    }
}
